The purpose of a database is to store and retrieve related information. In general, a database server reliably manages a large amount of data in a multi-user environment so that many users can concurrently access the same data.
A database, such as an Oracle database, has logical structures and physical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting the access to logical storage structures.
Every Oracle database has one or more physical datafiles. A datafile conforms to the operating system in which the database is running. The datafiles contain all the database data. The data of logical database structures, such as tables and indexes, are physically stored in datafiles allocated for a database. Once a datafile is allocated to a database, the disk blocks are formatted and set aside for exclusive use by the database system.
One or more datafiles form a logical unit of database storage called a tablespace. Each database is logically divided into one or more tablespaces, and each of the tablespaces consists of one or more datafiles. The combined size of the datafiles in a tablespace is the total storage capacity of the tablespace. A simple database may consist of one physical datafile that stores the data of one logical tablespace. Another database may consist of six datafiles that store the data of three tablespaces, wherein each tablespace consists of two datafiles.
More layers of logical structure exist under the logical structure of a tablespace. Referring to FIG. 1, at the finest level of granularity, Oracle database data is stored in data blocks 101. One data block corresponds to a specific number of bytes of physical database space on disk. The next level of logical database space is an extent 103. An extent is a specific number of contiguous data blocks allocated for storing a specific type of information. The level of logical database storage greater than an extent is called a segment. A segment 105 is a set of extents, each of which has been allocated for a specific data structure and all of which are stored in the same tablespace. For example, each table's data is stored in its own data segment, while each index's data is stored in its own index segment. If the table or index is partitioned, each partition is stored in its own segment.
The logical storage structures of an Oracle database system are fully described in the Oracle 10g documentation, including in a publication entitled “Oracle Database: Concepts,” 10g Release 2 (10.2), B14220-02, October 2005, the contents of which are hereby incorporated by reference as if fully set forth herein.
When a database is created in Oracle, at least one datafile and one tablespace are created for the database. The datafile is logically divided up into data blocks. A data block is the smallest unit of data used by a database. When a table is created in the database, Oracle allocates to the table's segment an initial extent of a specified number of contiguous data blocks. Although no rows have been inserted into the table, the data blocks that correspond to the initial extent are reserved for that table's rows.
When the existing space in a segment is completely used, then the database server allocates a new extent for the segment. To allocate a new extent, the server first determines a candidate datafile within the tablespace. The datafile's metadata is examined to determine if the datafile has the required number of adjacent free blocks. If that datafile does not have enough adjacent free space, then the server looks in another datafile. If no datafiles in the tablespace has enough adjacent free space, then the database server may request space from outside the database system to be allocated into the database system. The server requests from the disk subsystem, allocation of a new datafile to the tablespace. The server may also request the extension of an existing datafile. These operations are very expensive, requiring crossing between the domains of the database system and the underlying file system, and should be minimized. In order for a file system to allocate more disk space as datafile space for the database, a cleansing process must occur, including disk-write operations like physically writing 0s to the part of the disk being allocated.
In a prior approach, Oracle provides proactive help in managing tablespaces by triggering alerts to a database administrator, who can access the alert through a control interface. The alerts are either a warning or a critical alert. The warning threshold is the limit at which space is beginning to run low. The critical threshold is a serious limit that warrants a database administrator's immediate attention. The thresholds that trigger an alert are either based on percentage-full or by kilobytes of free space remaining, regardless of the rate of consumption over time. Thus, allocation that is in response to these alerts may not be sufficient to fulfill a user's demand for space if a large amount of space is suddenly needed within a short period of time. No alerts exist for managing space in the extent or segment layer.
In a highly concurrent environment, for example, where an online retailer experiences a surge of database activity that requires the insertion of hundreds of thousands of rows in the database within minutes, a database server operating under the prior approach to space allocation will not satisfy the demand for space in a timely manner. In such an environment, an extent will be filled just as soon as it is allocated. The throughput on the database server will nearly drop to zero as the server constantly needs to examine datafiles for free contiguous data blocks to be allocated as extents. Furthermore, allocating new datafiles is also an expensive operation that involves time-consuming cross-domain system calls and disk-write operations. If such a highly concurrent environment reaches full capacity, then the processing of insertion requests from concurrent users will grind to a halt as the system allocates new space to each layer.
A prior approach to managing space for schema objects in an Oracle database system is fully described in the Oracle 10g documentation, including in a publication entitled, “Oracle Database: Administrator's Guide,” 10g Release 2 (10.2), B14231-02, May 2006, the contents of which are hereby incorporated by reference as if fully set forth herein.
It would be advantageous for a database system to proactively allocate space to a logical layer of the database, as needed, and to complete the allocation in a timely manner, before the layer reaches full capacity.
The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.